package org.zyj.io.example.case6;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.zyj.io.example.codec.protobuf.StudentDto;

/**
 * 描述
 *
 * @author zhouyijin
 * @date 2022-01-14 14:48:54
 */
public class ProtobufServerHandler2 extends SimpleChannelInboundHandler<StudentDto.Student> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, StudentDto.Student msg) throws Exception {
        System.out.println("客户端发送的数据: " + msg);
    }

    //处理异常, 一般情况是关闭通道
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }
}
